﻿using System;
using System.Collections.Generic;


namespace OurSite.Business.Category
{
    public class CategoryLight
    {
        protected List<CategoryLight> subCategories = new List<CategoryLight>();

        public Guid Id { get; set; }
        public string Name { get; set; }
        public Guid ParentId { get; set; }
        public string ParentName { get; set; }
        public List<CategoryLight> SubCategories
        {
            get { return subCategories; }
            set { subCategories = value; }
        }

        public CategoryLight() {}

        public CategoryLight(Category category)
        {
            Id = category.Id;
            Name = category.Name;

            if (category.ParentCategory != null)
            {
                ParentId = category.ParentId;
                ParentName = category.ParentCategory.Name;
            }

            foreach (var sub in category.SubCategories)
            {
                SubCategories.Add(new CategoryLight(sub));
            }
        }
    }
}
